#ifndef GROUPCHAT_H
#define GROUPCHAT_H

#include <QWidget>
#include <QGroupBox>
#include <QVBoxLayout>
#include "../MeetingServer/messagepackage.h"

namespace Ui {
class GroupChat;
}

class GroupChat : public QWidget
{
    Q_OBJECT

public:
    explicit GroupChat(QString sender, QString groupName, QWidget *parent = nullptr);
    ~GroupChat();
protected:
    virtual void closeEvent(QCloseEvent *event) override;
private:
    QGroupBox *createMessageBox(const QString &sender, const QString &message, const QString &time);
    void widgetVisible();
private slots:
    void on_ptn_send_clicked();

    void on_btn_invite_clicked();

    void on_btn_share_clicked();

public slots:
    void onNewGroupInfo(messagePackage pack);
private:
    Ui::GroupChat *ui;
    QVBoxLayout *chatHistoryLayout;
    QString sender;
    QString groupName;
    int hour = 0;
    int min = 0;
signals:
    void sendInfo(QString sender, QString groupName, QString info, QString time);
    void chatClose(QString receiver);
    void inviteGroup(QString user, QString groupName);
};

#endif // GROUPCHAT_H
